#!/usr/bin/python3
import http.client,urllib.parse,json,nconfig

#get token
headers = {}
conn = http.client.HTTPConnection(nconfig.Server_IP,nconfig.Server_Port)
conn.request('POST', nconfig.TK_URL, json.dumps(nconfig.Server_Login), headers)
response = conn.getresponse()
print(response.status, response.reason)
data2 = response.read().decode('utf-8')
#print(data2)
#conn.close()

ttt=json.loads(data2)
nconfig.TK_Data["_TK"]=ttt["_TK"]
#print(ttt)
#print(nconfig.TK_Data)

test_URL=nconfig.Output[4]
#print( json.dumps(nconfig.Data))

#conn = http.client.HTTPConnection(nconfig.Server_IP,nconfig.Server_Port)
conn.request('POST', test_URL["url"], json.dumps(nconfig.send_data[4]), nconfig.TK_Data)
response = conn.getresponse()
print(response.status, response.reason)
data3 = response.read().decode('utf-8')
print(data3)
conn.close()
obj=json.loads(data3)
list=obj['body']
#print(json.dumps(nconfig.test_data))
#print(list)
#print(list[0])
#print(list[1])
#t=ttt['sites']
#r=t[2]
#print(r['name'])
#print(r['t'])
#print(r['pager'])
